package com.ruoyi.business.controller.mini;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.framework.web.service.SysLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mini/login")
@Api(value = "login",tags = "登录")
public class LoginController extends BaseController {

    @Autowired
    private SysLoginService loginService;

    /**
     * 登录通过密码
     * @param loginBody
     * @return
     */
    @ApiOperation("账号密码登录")
    @PostMapping("/open/loginByPassword")
    public R loginByPassword(@RequestBody  LoginBody loginBody) {
        // 生成令牌
        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
                loginBody.getUuid());
        return R.success(null,token);
    }


}
